<?php
class index
{
	public function defaultaction()
	{
		$connection = db::factory('mysql');
		
		/* Counts the items */
		$sql = "SELECT count(*) count,type,result FROM Items GROUP BY type,result";
		$counts = $connection->getArray($sql);
		
		$count = array_fill(0, 2, array(0,0));
		
		foreach($counts as $c){
			$count[$c['type']][$c['result']] = $c['count'];
		}
		
		$tags = new tagscollection(new tag());
		$tags->getwithdata();
		
		echo view::show('index', array(
			'lostcount'=>	$count[0][0],
			'getbackcount'=>$count[0][1],
			'foundcount'=>	$count[1][0],
			'returncount'=>	$count[1][1],
			'tags'=>$tags));
	}
}